-- quantum_mechanics
-- created by shuzy
-- 将敌人生命更改成为指定值

return {
    apply = function(source, target, skillId, round, para, extra)
        -- 如果免疫了该技能
        if SkillM.immunitySkill(source, target, skillId) then
            SkillM.getSequence(target):immunity(source, target, skillId);
            return {};
        end

        -- 如果是boss
        if target:isBoss() then
            return {};
        end

        local effectRound = -1;
        extra = extra or {};
        local lastRound = extra.lastRound;

        if type(lastRound) == "number" then
            effectRound = round + lastRound + 1;
        elseif para[2] > 0 then
            local v = para[2];

            -- 不包括本回合
            effectRound = round + v;
        end

        -- 血量减少
        local currHp = target:getHp("hp");
        local statusHp = para[1];
        target:setRealHp(statusHp);
        
        local reduceHp = currHp - statusHp;

        -- 量子状态
        local condition = {
            ["hp"] = statusHp,
            ["reduce"] = reduceHp,
            ["end_round"] = effectRound,
        };

        CombatStatusM.applyStatus(target, "quantum_mechanics", condition);

        -- 增加命中动作
        SkillM.getSequence(target):hit(source, target, skillId);

        -- 作用目标
        return { target, };
    end,

    parse = function(desc)
        local arr = string.explode(desc, ",");
        return { tonumber(arr[1]), tonumber(arr[2] or -1), };
    end,

    -- 解析技能描述
    parseDesc = function(source, skillId, desc, para)
        return desc;
    end,
};
